#ifndef UHM_DISCRETE_IO_MESH2STREAM_HXX_
#define UHM_DISCRETE_IO_MESH2STREAM_HXX_

namespace uhm {

  template<class Mesh_> Bool_ mesh2stream(Mesh_ &mesh, 
                                          Int_ n_node_var, Int_ is_high, 
                                          Int_ n_element_var,
                                          std::ostream &stream) {

    time_in("uhm:: mesh2stream",UHM_TIME_LEVEL_INTERNAL);

    if (get_verbose())
      std::cout << "Writing mesh to file" << std::endl;
    
    stream << "# Format\n";
    stream << "STREAM\n";

    stream << "# n_node_var, is higher node\n";
    stream << n_node_var << " " << is_high << "\n";
    
    // --------- Writing nodes
    stream << "# n nodes\n";
    stream << mesh.get_n_nodes() << "\n";
    
    stream << "# n_element_var\n";
    stream << n_element_var << "\n";

    stream << "# n elements\n";
    stream << mesh.get_n_elements() << "\n";

    if (get_verbose())
      std::cout << "Done" << std::endl;

    time_out(UHM_TIME_LEVEL_INTERNAL);

    return true;
  }

}

#endif
